<%

Function usuario_novo_usuario(login, email)

		if verificar_login_existe(login) AND verificar_email_existe(email) AND IsEmail(email) AND login_valido(login) then

				DIM data, codigo, mensagem
				
				codigo = md5(randomico(1, 999999))
	
				data = get_data()
		
				str = "INSERT into usuarios_temp "
				str = str & "(login, email, data, codigo) "
				str = str & "VALUES ('" & login & "', "
				str = str & "'" & email & "', "		
				str = str & "'" & data & "', "		
				str = str & "'" & codigo & "')"						
				Set rsI = conexao_geral.Execute(str)
				
				str = "Select id FROM usuarios_temp where login='"&login&"'"
   				Set rs = conexao_geral.Execute(str)	
				
				mensagem = mensagens_prontas(1, "login|id|codigo", login&"|"&rs("id")&"|"&codigo)
				
				mensagens_enviar_email "Barbolão", login, email, "Cadastro", mensagem
				
				usuario_novo_usuario = TRUE
		
		Else
		
				usuario_novo_usuario = FALSE
		
		End If

End Function

Function verificar_login_existe(login)

		str = "Select id FROM usuarios where login='"&login&"'"
   		Set rs = conexao_geral.Execute(str)	
		
		str = "Select id FROM usuarios_temp where login='"&login&"'"
   		Set rs2 = conexao_geral.Execute(str)	
		
		If rs.eof and rs2.eof then
			verificar_login_existe=TRUE
		Else
			verificar_login_existe=FALSE
		End If

End Function

Function verificar_email_existe(email)

		str = "Select id FROM usuarios where email='"&email&"'"
   	Set rs = conexao_geral.Execute(str)	
		
		str = "Select id FROM usuarios_temp where email='"&email&"'"
   	Set rs2 = conexao_geral.Execute(str)	
		
		If rs.eof and rs2.eof then
			verificar_email_existe=TRUE
		Else
			verificar_email_existe=FALSE		
		End If

End Function

Function login_valido(login)
		
		DIM valor
		
		valor = configuracoes_get("max_caracter_login")
		
		DIM st
		st=TRUE
		
		If len(login)>Int(valor) then
			st=FALSE
		End If
		
		login_valido=st		

End Function

%>
